window.onscroll=function(){
		var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
		var header=document.getElementById("header");
		var J_tab=document.getElementsByClassName("J-tab")[0];
        var bodyheight=$(document.body).height();
		// console.log(bodyheight);
		if(header)
		{
            var sdheight=$(".slider").height();
            var speed=(scrollTop-sdheight)/500;
			if(scrollTop>sdheight){
			header.style.backgroundColor="rgba(229, 131, 53, "+speed+")";
			}
			else{
				header.style.backgroundColor="rgba(229, 131, 53, 0)";
			}
		}
		if(J_tab){
			var de_scrTop=J_tab.offsetTop;
			var trigger_list=J_tab.getElementsByClassName("trigger-list")[0];
			if(scrollTop>de_scrTop){
				trigger_list.className="trigger-list fixed";
			}
			else{
				trigger_list.className="trigger-list";
			}
		}
        if(scrollTop>bodyheight/7){
            
        }
}
$(document).ready(function() {
	$(".footer-nav").click(function() {
		$(this).toggleClass('show');
	});
	$(".a-search-ipt").blur(function() {
		$("#J_search_pt").removeClass('active');
	});
	$(".mem-info").append('<div class="outbox"><a href="passport-logout.html" class="logout">退出登录</a></div>');
	$(".product-page").on("click","#J_mask",function(){
　　　　$(".dialog").css("display","none");
		$(this).css("display","none");
  });
    $(".back-top").click(function() {
        // scroll('0px', 1000);
        goTop();
    });
    /*图片滚动*/
    var ptSlider = $('#J_pt_slider');
    var inner=ptSlider.find('.slider-list');
    var item = inner.find('.slider-item');
    var sl = item.size();
    var sw = item.width() + parseInt(item.css('margin-left')) + parseInt(item.css('margin-right'));
    var speed = 500;
    var act = 0;
    var x1,x2, direct;
    function transformBox(obj,value,time){
        var time=time?time:0;
        transl="translate3d("+value+"px,0,0)";
        obj.css({'-webkit-transform':transl,'-webkit-transition':time+'ms linear'});
    }
    inner.css({'width':sl * sw, '-webkit-transform': 'translate3d(0,0,0)'});
    ptSlider.on('touchstart', function(e) {
        if(x2) x2 = undefined;
        x1 = e.touches[0].pageX;
    })
    .on('touchmove', function(e){
        e.preventDefault();
        x2 = e.touches[0].pageX;
        var offset= x2-x1+act*sw;
        transformBox(inner,offset,0);
    })
    .on('touchend', function(e) {
        if(x1 > x2) direct = 'left';
        else direct = 'right';
        if(Math.abs(x1 - x2) < 30) 
        transformBox(inner,act * sw,100);
    })
    .swipe(function(e){
        var offset;
        if(direct == 'left') {
            --act;
        }
        else {
            ++act;
        }
        if(act == 1){
            act = 0;
        }
        else if(act == -sl){
            act = - sl + 1;
        }
        offset=act*sw;
        transformBox(inner, offset,speed);
        $(this).next().children().eq(Math.abs(act)).addClass('act').siblings('.act').removeClass('act');
    });
    /*图片滚动End*/
})

// /*返回顶部*/ 
// function scroll(scrollTo, time) {
//     var scrollFrom = parseInt(document.body.scrollTop),
//     i = 0,
//     runEvery = 5; // run every 5ms
//     scrollTo = parseInt(scrollTo);
//     time /= runEvery;
//     var interval = setInterval(function () {
//     i++;
//     document.body.scrollTop = (scrollTo - scrollFrom) / time * i + scrollFrom;
//     if (i >= time) {
//     clearInterval(interval);
//     }
//     }, runEvery);
// }
/*返回顶部*/ 
// function goTop(acceleration, time) {
// acceleration = acceleration || 0.1;
// time = time || 16;
// var x1 = 0;
// var y1 = 0;
// var x2 = 0;
// var y2 = 0;
// var x3 = 0;
// var y3 = 0;
// if (document.documentElement) {
// x1 = document.documentElement.scrollLeft || 0;
// y1 = document.documentElement.scrollTop || 0;
// }
// if (document.body) {
// x2 = document.body.scrollLeft || 0;
// y2 = document.body.scrollTop || 0;
// }
// var x3 = window.scrollX || 0;
// var y3 = window.scrollY || 0;
// // 滚动条到页面顶部的水平距离
// var x = Math.max(x1, Math.max(x2, x3));
// // 滚动条到页面顶部的垂直距离
// var y = Math.max(y1, Math.max(y2, y3));
// // 滚动距离 = 目前距离 / 速度, 因为距离原来越小, 速度是大于 1 的数, 所以滚动距离会越来越小
// var speed = 1 + acceleration;
// window.scrollTo(Math.floor(x / speed), Math.floor(y / speed));
// // 如果距离不为零, 继续调用迭代本函数
// if (x > 0 || y > 0) {
// var invokeFunction = "goTop(" + acceleration + ", " + time + ")";
// window.setTimeout(invokeFunction, time);
// }
// }
